//
//  MainController.m
//  StudyingDemo
//
//  Created by GuoMS on 2018/6/9.
//  Copyright © 2018年 gms. All rights reserved.
//

#import "MainController.h"
#import "KVOController.h"
#import "KVCController.h"
#import "OMColor.h"
#import "TextController.h"

@interface MainController ()<UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) NSMutableArray *dataArr;

@end

@implementation MainController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的目录";
    
    self.tableView.tableFooterView = [UIView new];
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    cell.textLabel.text = self.dataArr[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSInteger row = indexPath.row;
    switch (row) {
        case 0:
        {
            KVOController *kvo = [KVOController new];
            [self.navigationController pushViewController:kvo animated:YES];
        }
            break;
            
        case 1:
        {
            KVCController *kvc = [KVCController new];
            [self.navigationController pushViewController:kvc animated:YES];
        }
            break;
        case 2:
        {
            TextController *txt = [TextController new];
            [self.navigationController pushViewController:txt animated:YES];
        }
            break;
        case 3:
            
            break;
    }
}

- (NSMutableArray *)dataArr {
    
    if (!_dataArr) {
        NSArray *arr = @[@"KVO",@"KVC",@"textview",@"runloop"];
        _dataArr = [NSMutableArray arrayWithArray:arr];
    }
    
    return _dataArr;
}



@end
